import { ModalForm, ModalFormProps } from '@ant-design/pro-components'
import type { BasicModalProps } from './index.type'
import styles from './index.module.less'

interface Props extends Omit<ModalFormProps, 'open' | 'modalProps'> {
  register: BasicModalProps['register']
}

export default function BasicModal(props: Props) {
  const { register, children, ...argsProps } = props
  const { visible, onClose } = register()

  return (
    <ModalForm
      {...argsProps}
      open={visible}
      modalProps={{
        destroyOnClose: true,
        onCancel: onClose,
        className: styles.basicModal
      }}
    >
      {children}
    </ModalForm>
  )
}
